
//
//  TurnView.swift
//  weibo1
//
//  Created by Apple on 15/12/3.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class TurnView: UIView {
    
    var turnstatuses: statuses? {
        //MARK: 有问题
        
        didSet{
        
            textLabel.text = "@" + (turnstatuses?.user?.name ?? "") + ":" + (turnstatuses?.text ?? "")
        //给图片赋值
        
        }
        
    }
    
    
    
    
    //MARK: 重写构造方法
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //MARK: 设置UI 及布局
    private func setupUI() {
         backgroundColor = UIColor(white: 0.95, alpha: 1)
        addSubview(textLabel)
        addSubview(pictureImage)
        
       textLabel.snp_makeConstraints { (make) -> Void in
        make.top.left.equalTo(self).offset(OffsetCell)
        }
        pictureImage.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(textLabel.snp_bottom).offset(OffsetCell)
            make.left.equalTo(textLabel.snp_left)
            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureImage.snp_bottom).offset(OffsetCell)
        }
        
    }
    
    //MARK: 懒加载所有的子控件
    //文本
    private lazy var textLabel: UILabel = {
        let labe = UILabel()
        labe.text = "转发微博"
        labe.textColor = UIColor.blackColor()
        labe.font = UIFont.systemFontOfSize(14)
        //换行
        labe.numberOfLines = 0
        //设定label的宽度
        labe.preferredMaxLayoutWidth = ScreenW - 2 * OffsetCell
        //自动填充
        labe.sizeToFit()
        return labe
  
    }()
    //配图
    private lazy var pictureImage: LayouView = LayouView()
    
}
